package com.itheima.tlias.mapper;

import com.itheima.tlias.pojo.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface StudentMapper {
	@Select("select * from student where id = #{id}")
	Student getById(Integer id);

	List<Student> page(Integer clazzId, Integer degree, String name);

	@Insert("insert into student(name, no, phone, gender, degree, id_card, is_college, address, graduation_date, violation_count, violation_score, clazz_id, create_time, update_time) " +
			"values(#{name} , #{no}, #{phone}, #{gender}, #{degree}, #{idCard}, #{isCollege}, #{address}, #{graduationDate}, #{violationCount}, #{violationScore}, #{clazzId}, #{createTime}, #{updateTime})")
	void save(Student student);

	//@Delete("delete from student where id = #{id}")
	//void deleteById(Integer id);

	void deleteByIds(List<Integer> ids);

	@Update("update student set violation_score = #{score},violation_count = violation_count+1 where id =#{id}")
	void updateScore(Integer id, Integer score);

	void update(Student student);

	//@Select("select name from tlias.student")
	@MapKey("name")
	List<Map<String, Object>> getDegreeData();

	@MapKey("clazzList")
	List<Map<String, Object>> getStudentCountData();
}
